<?php

// no direct access
defined('_JEXEC') or die('Restricted access'); 

jimport( 'joomla.application.component.view' );
class SimplelistingViewLanguages extends JView
{	
	function display($tpl = null)
	{	
	global $mainframe;
	$option = JRequest::getVar('option');	
	
	$doc =& JFactory::getDocument();

//	$doc->addStyleSheet('components/'.$option.'/includes/css/index.css');
	
        if(JRequest::getVar('layout')=='edit'){

            JToolBarHelper::save( 'saveLanguage' );
            JToolBarHelper::apply( 'applyLanguage');
            JToolBarHelper::cancel('cancel');
            JToolBarHelper::title(JText::_('TITLE_MAIN'). ' [ ' . JText::_( 'TITLE_TRANSLATION' ) .' - '. JText::_( 'TITLE_EDIT' ). ' ]' , 'info.png' );
        } else {
            JToolBarHelper::back( 'Control Panel', 'index.php?option=com_simplelisting' );
            JToolBarHelper::custom( 'editLanguage', 'edit.png', 'edit_f2.png', 'Edit', true );
            JToolBarHelper::title(JText::_('TITLE_MAIN'). ' [ ' . JText::_( 'TITLE_TRANSLATION' ) . ' ]', 'info.png' );

        $option 	= JRequest::getCmd('option');
        //$clientSite		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
        $client		=& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));

        $language =& JFactory::getLanguage();
        $lang = JRequest::getVar('id', $language->getTag(), 'method', 'cmd');
        $dir = $client->path.DS.'language'.DS.$lang;

        jimport('joomla.filesystem.folder');
        $files = JFolder::files($dir, '\.ini$', false, false);

        jimport('joomla.client.helper');

        JClientHelper::setCredentialsFromRequest('ftp');

        $this->assignRef('client', $client);
        $this->assignRef('lang', $lang);
        $this->assignRef('dir', $dir);
        $this->assignRef('files', $files);

	jimport('joomla.filesystem.folder');
	$path = JLanguage::getLanguagePath($client->path);
	$dirs = JFolder::folders( $path );
	$this->assignRef('dirs', $dirs);
	
        }
        parent::display($tpl);
    }
}
